<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <title>供应商竞价</title>
    <script type="text/javascript">
      Ext.onReady(function(){

        //供应商信息

        var vendorUnitPrice = new Ext.form.NumberField({
          fieldLabel: '单价',
          name: 'unit_price',
          allowBlank: false,
          allowDecimals: false,
          allowNegative: false,
          readOnly:true,
          anchor: '90%'
        });
        
        var vendorAmount = new Ext.form.NumberField({
          fieldLabel: '总价',
          name: 'amount',
          allowBlank: false,
          allowDecimals: false,
          allowNegative: false,
          readOnly: true,
          anchor: '90%'
        });

        var vendorBrand = new Ext.form.TextField({
          fieldLabel: '品牌',
          allowBlank: false,
          readOnly:true,
          name: 'brand',
          anchor: '90%'
        });
        
        var vendorModel = new Ext.form.TextField({
          fieldLabel: '型号',
          allowBlank: false,
          readOnly:true,
          name: 'model',
          anchor: '90%'
        });

        var vendorSpec = new Ext.form.TextField({
          fieldLabel: '规格',
          readOnly:true,
          name: 'specification',
          anchor: '90%'
        });

        var vendorManu = new Ext.form.TextField({
          fieldLabel: '生产单位',
          readOnly:true,
          name: 'manufacturer',
          anchor: '90%'
        });

        var vendorQualification = new Ext.form.TextArea({
          fieldLabel: '主要技术指标',
          name: 'qualification',
          readOnly:true,
          height:50,
          anchor: '97%'
        });

        var servicePromise = new Ext.form.TextArea({
          fieldLabel: '服务承诺',
          name: 'service_promise',
          readOnly:true,
          height:50,
          anchor: '97%'
        });

        //计算总额
        vendorUnitPrice.on('blur',countAmount);

        function countAmount(){
          vendorAmount.setValue(quantity.getValue()*vendorUnitPrice.getValue());
        }

        var reader = new Ext.data.JsonReader({
            root: 'root'
          }, [{
              name: 'unit_price'
            },{
              name: 'amount'
            },{
              name: 'brand'
            },{
              name: 'model'
            },{
              name: 'specification'
            },{
              name: 'manufacturer'
            },{
              name: 'qualification'
            },{
              name: 'service_promise'
            }]);
        
        var purchaseForm = new Ext.FormPanel({
          labelWidth: 75, 
          reader: reader,
          frame:true,
          labelAlign: 'right',
          buttonAlign: 'center',
          //title: '添加申购单',
          bodyStyle:'padding:5px 5px 0',
          width: 810,
          //height:300,
          items: [{
              xtype: 'fieldset',
              defaults: {width: 770},
              title: '<font color=green>供应商的竞价</font>',
              border: true,
              items: [{
                  layout: 'column',
                  border: false,
                  items: [{
                      columnWidth: .25,
                      layout: 'form',
                      border: false,
                      items: [vendorUnitPrice]
                    },{
                      columnWidth: .25,
                      layout: 'form',
                      border: false,
                      items: [vendorAmount]
                    }]
                },{
                  layout: 'column',
                  border: false,
                  items: [{
                      columnWidth: .25,
                      layout: 'form',
                      border: false,
                      items: [vendorBrand]
                    },{
                      columnWidth: .25,
                      layout: 'form',
                      border: false,
                      items: [vendorModel]
                    },{
                      columnWidth: .25,
                      layout: 'form',
                      border: false,
                      items: [vendorSpec]
                    },{
                      columnWidth: .25,
                      layout: 'form',
                      border: false,
                      items: [vendorManu]
                    }]
                },{
                  layout: 'column',
                  border: false,
                  items: [{
                      columnWidth: 1,
                      layout: 'form',
                      border: false,
                      items: [vendorQualification]
                    }]
                },{
                  layout: 'column',
                  border: false,
                  items: [{
                      columnWidth: 1,
                      layout: 'form',
                      border: false,
                      items: [servicePromise]
                    }]
                }]
            }],
          buttons: [{
              text: '取消',
              handler: function(){
                purchaseForUserWin.destroy();
              }
            }]
        });

        purchaseForm.form.load({
          url: '/purchase/viewOffer?id=<%=params[:id]%>',
          waitMsg: '正在载入数据...',
          success: function(form, action){
          },
          failure: function(form, action){
            Ext.MessageBox.alert('提示信息', '信息加载失败');
          }
        });
        
        purchaseForm.render('offer_form');
      })
    </script>
  </head>
  <body>
    <div id="offer_form"></div>
  </body>
</html>
